package com.sunni.controller;

import com.sunni.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@RequestMapping("/demo")
@Component("demoController")
public class DemoController {

    @Autowired
    @Qualifier("demoService")
    private DemoService demoService;
    // 1.数据转化异常    把"aaaa"转成数字, 报类型转化异常

    @RequestMapping("/test1")
    @ResponseBody
    public void testClassCastException(){
        demoService.testClassCastException();
    }

    @RequestMapping("/test2")
    @ResponseBody
    public void testChuFaException(){
        demoService.testChuFaException();
    }

    @RequestMapping("/test3")
    @ResponseBody
    public void testOthersException() throws Exception {
        throw new Exception();
    }

}
